package com.letv.whatslive.model.convert;

import com.letv.whatslive.model.Carousel_ImageSrc;
import com.letv.whatslive.model.utils.ObjUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

/**
 * Created by Administrator on 2016/4/19.
 */
public class Carousel_ImageSrcConvert {
    public static DBObject castCarousel_ImageSrcToDBObject(Carousel_ImageSrc carousel_ImageSrc) {
        DBObject dbo = new BasicDBObject();
        if (carousel_ImageSrc.getId() != null) {
            dbo.put("_id", carousel_ImageSrc.getId());
        }
        dbo.put("picUrl", ObjUtils.toString(carousel_ImageSrc.getPicUrl(), ""));
        dbo.put("adUrl", ObjUtils.toString(carousel_ImageSrc.getAdUrl(), ""));
        dbo.put("createTime", ObjUtils.toLong(carousel_ImageSrc.getCreateTime(), 0l));
        dbo.put("updateTime", ObjUtils.toLong(carousel_ImageSrc.getUpdateTime(), 0l));
        dbo.put("type", ObjUtils.toInteger(carousel_ImageSrc.getType(), 0));
        dbo.put("busiId", ObjUtils.toString(carousel_ImageSrc.getBusiId(),""));
        dbo.put("appId", ObjUtils.toLong(carousel_ImageSrc.getAppId()));
        dbo.put("priority", ObjUtils.toLong(carousel_ImageSrc.getPriority(), 0l));
        return dbo;

    }

    public static Carousel_ImageSrc castDBObjectToCarousel_ImageSrc(DBObject dbObject) {
        Carousel_ImageSrc carousel_ImageSrc = new Carousel_ImageSrc();
        if (dbObject != null) {
            carousel_ImageSrc.setId(ObjUtils.toLong(dbObject.get("_id")));
            carousel_ImageSrc.setPicUrl(ObjUtils.toString(dbObject.get("picUrl")));
            carousel_ImageSrc.setAdUrl(ObjUtils.toString(dbObject.get("adUrl")));
            carousel_ImageSrc.setCreateTime(ObjUtils.toLong(dbObject.get("createTime")));
            carousel_ImageSrc.setUpdateTime(ObjUtils.toLong(dbObject.get("updateTime")));
            carousel_ImageSrc.setType(ObjUtils.toInteger(dbObject.get("type"), 0));
            carousel_ImageSrc.setBusiId(ObjUtils.toString(dbObject.get("busiId")));
            carousel_ImageSrc.setAppId(ObjUtils.toLong(dbObject.get("appId")));
            carousel_ImageSrc.setPriority(ObjUtils.toLong(dbObject.get("priority")));
        }

        return carousel_ImageSrc;
    }
}
